package com.gtw.modules.api.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.gtw.modules.api.service.TbCategoryService;
import com.gtw.modules.dao.TbCategoryDao;
import com.gtw.modules.entity.TbCategory;
import com.gtw.modules.entity.TbUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
public class TbCategoryServiceImpl implements TbCategoryService {

    @Autowired
    private TbCategoryDao tbCategoryDao;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        TbCategory tbCategory = tbCategoryDao.selectByPrimaryKey(id);
        tbCategory.setIsdelete(true);
        return tbCategoryDao.updateByPrimaryKey(tbCategory);
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public int insert(TbCategory record) {
        return tbCategoryDao.insert(record);
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public int insertSelective(TbCategory record) {
        return tbCategoryDao.insertSelective(record);
    }

    @Override
    public TbCategory selectByPrimaryKey(Integer id) {
        return tbCategoryDao.selectByPrimaryKey(id);
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public int updateByPrimaryKeySelective(TbCategory record) {
        return tbCategoryDao.updateByPrimaryKeySelective(record);
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public int updateByPrimaryKey(TbCategory record) {
        return tbCategoryDao.updateByPrimaryKey(record);
    }

    @Override
    public Page<TbCategory> queryPageList(Page<TbCategory> page, Map<String, Object> map) {
        page.setRecords(tbCategoryDao.queryPageList(page, map));
        return page;
    }

    @Override
    public List<TbCategory> queryList(Map<String, Object> map) {
        return tbCategoryDao.queryList(map);
    }

    @Override
    public List<TbCategory> findALL() {
        return tbCategoryDao.findAll();
    }

}
